<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 2018/5/29
 * Time: 上午11:20
 */

namespace app\admin\controller;


use extend\Functions;
use think\Request;

class Configure extends Auth
{
    /**
     * @purpose 获取活动客服电话
     * @param Request $request
     * @return array
     */
    public function getActivityCustomer ()
    {
        return \app\admin\logic\Configure::getConfigure('activity_customer');
    }
    /**
     * @purpose 设置活动客服电话
     * @param Request $request
     * @return array
     */
    public function setActivityCustomer (Request $request)
    {
        $data       = $request->post();
        return \app\admin\logic\Configure::setConfigure('activity_customer', $data, '活动客服电话');
    }
    /**
     * @purpose 获取APP版本
     * @param Request $request
     * @return array
     */
    public function getAppUpgradeWgt (Request $request)
    {
        $os     = strtolower($request->get('os'));
        return \app\admin\logic\Configure::getConfigure('upgrade_wgt_'.$os);
    }
    /**
     * @purpose 设置APP版本配置
     * @param Request $request
     * @return array
     */
    public function setAppUpgradeWgt (Request $request)
    {
        $os     = strtolower($request->post('os'));
        $data   = $request->post('data');
        $desc   = '';
        if ($os === 'ios') {
            $desc = 'ios更新资源版本';
        } else if ($os = 'android') {
            $desc = 'android更新资源版本';
        }
        return \app\admin\logic\Configure::setConfigure('upgrade_wgt_'.$os, $data, $desc);
    }
    /**
     * @purpose 获取APP版本
     * @param Request $request
     * @return array
     */
    public function getAppUpgrade (Request $request)
    {
        $os     = strtolower($request->get('os'));
        return \app\admin\logic\Configure::getConfigure('upgrade_'.$os);
    }
    /**
     * @purpose 设置APP版本配置
     * @param Request $request
     * @return array
     */
    public function setAppUpgrade (Request $request)
    {
        $os     = strtolower($request->post('os'));
        $data   = $request->post('data');
        $desc   = '';
        if ($os === 'ios') {
            $desc = 'ios更新版本';
        } else if ($os = 'android') {
            $desc = 'android更新版本';
        }
        return \app\admin\logic\Configure::setConfigure('upgrade_'.$os, $data, $desc);
    }
    /**
     * @purpose 获取权限白名单
     * @return array|mixed
     */
    public function getRuleWhiteList () {
        return \app\admin\logic\Configure::getConfigure('rule_white_list');
    }

    /**
     * @purpose 设置路由白名单
     * @param Request $request
     * @return array|mixed
     */
    public function setRuleWhiteList (Request $request) {
        $config = $request->post();
        return \app\admin\logic\Configure::setConfigure('rule_white_list', $config, '总后台路由白名单');
    }

    /**
     * @purpose 设置应用首页轮播图
     * @param Request $request
     * @return array
     */
    public function setAppSwiper (Request $request) {
        $swiper = $request->post();
        $swiper = Functions::array_sort($swiper, 'sort');
        return \app\admin\logic\Configure::setConfigure('app_swiper', $swiper, '引用首页轮播图');
    }

    /**
     * @purpose 获取应用首页轮播图
     * @param Request $request
     * @return array
     */
    public function getAppSwiper () {
        return \app\admin\logic\Configure::getConfigure('app_swiper');
    }


    /**
     * @purpose 设置活动应用轮播图
     * @param Request $request
     * @return array
     */
    public function setActivitySlide (Request $request) {
        $swiper = $request->post();
        $swiper = Functions::array_sort($swiper, 'sort');
        return \app\admin\logic\Configure::setConfigure('activity_swiper', $swiper, '活动首页轮播图');
    }

    /**
     * @purpose 获取活动应用轮播图
     * @param Request $request
     * @return array
     */
    public function getActivitySlide () {
        return \app\admin\logic\Configure::getConfigure('activity_swiper');
    }
    /**
     * @purpose 设置应用首页的分类展示块
     * @param Request $request
     * @return array
     */
    public function setAppBlockItem (Request $request) {
        $swiper = $request->post();
        $swiper = Functions::array_sort($swiper, 'sort');
        return \app\admin\logic\Configure::setConfigure('app_block_item', $swiper, '应用首页的分类展示块');
    }
    /**
     * @purpose 获取应用首页的分类展示块
     * @param Request $request
     * @return array
     */
    public function getAppBlockItem () {
        return \app\admin\logic\Configure::getConfigure('app_block_item');
    }
    /**
     * @purpose 设置应用首页要展示的品牌
     * @param Request $request
     * @return array
     */
    public function setAppBrand (Request $request) {
        $swiper = $request->post();
        $swiper = Functions::array_sort($swiper, 'sort');
        return \app\admin\logic\Configure::setConfigure('app_brand', $swiper, '首页要展示的品牌');
    }
    /**
     * @purpose 获取应用首页要展示的品牌
     * @param Request $request
     * @return array
     */
    public function getAppBrand () {
        return \app\admin\logic\Configure::getConfigure('app_brand');
    }
    /**
     * @purpose 设置分销提成遍历
     * @param Request $request
     * @return array
     */
    public function setDistributionRatio (Request $request) {
        $data = $request->post();
        return \app\admin\logic\Configure::setConfigure('distribution_ratio', $data, '分销比例');
    }
    /**
     * @purpose 获取分销提成比例
     * @param Request $request
     * @return array
     */
    public function getDistributionRatio () {
        return \app\admin\logic\Configure::getConfigure('distribution_ratio');
    }
    /**
     * @purpose 设置代理商升级配置
     * @param Request $request
     * @return array
     */
    public function setAgentUpgrade (Request $request) {
        $data = $request->post();
        return \app\admin\logic\Configure::setConfigure('agent_upgrade', $data, '代理商升级配置,invitation单位为人,pay单位为元');
    }
    /**
     * @purpose 获取代理商升级配置
     * @param Request $request
     * @return array
     */
    public function getAgentUpgrade () {
        return \app\admin\logic\Configure::getConfigure('agent_upgrade');
    }

    /**
     * @purpose 设置客服微信
     * @param Request $request
     * @return array
     */
    public function setCustomerWechat (Request $request) {
        $data       = $request->post();
        return \app\admin\logic\Configure::setConfigure('customer_wechat', $data, '客服微信');
    }

    /**
     * @purpose 获取客服微信
     * @return array
     */
    public function getCustomerWechat () {
        return \app\admin\logic\Configure::getConfigure('customer_wechat');
    }
}